package com.tupi.project.view.refresh;

import android.content.Context;
import android.util.AttributeSet;

import in.srain.cube.views.ptr.PtrFrameLayout;

/**
 * author zhetengxiang
 * Date 2016/7/27
 */

public class RefreshLayout extends PtrFrameLayout
{
    
    private RefreshHeader mHeaderView;
    
    public RefreshLayout(Context context)
    {
        super(context);
        init();
    }
    
    public RefreshLayout(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        init();
    }
    
    public RefreshLayout(Context context, AttributeSet attrs, int defStyle)
    {
        super(context, attrs, defStyle);
        init();
    }
    
    private void init()
    {
        mHeaderView = new RefreshHeader(getContext());
        setHeaderView(mHeaderView);
        addPtrUIHandler(mHeaderView);
    }
    
    
    public RefreshHeader getHeader()
    {
        return mHeaderView;
    }
    
    /**
     * Specify the last update time by this key string
     *
     * @param key
     */
    public void setLastUpdateTimeKey(String key)
    {
        if (mHeaderView != null)
        {
            mHeaderView.setLastUpdateTimeKey(key);
        }
    }
    
    /**
     * Using an object to specify the last update time.
     *
     * @param object
     */
    public void setLastUpdateTimeRelateObject(Object object)
    {
        if (mHeaderView != null)
        {
            mHeaderView.setLastUpdateTimeRelateObject(object);
        }
    }
    
    
}
